// SPDX-License-Identifier: GPL-2.0-or-later
/**
 * @brief 系统变量模块数据定义
 * @version
 * @author ~ 宋炜
 * @date ~ 2023-3-30
 */
#ifndef FQTERM_PARAM_H
#define FQTERM_PARAM_H

#include <QString>
#include <QColor>
#include <QObject>

namespace FQTerm {


//The FQTerm Pref also contains global settings.
//TODO: move all global settings into FQTermPref.
struct FQTermPref {
    static FQTermPref* getInstance()
    {
        static FQTermPref* pThis = new FQTermPref();
        return pThis;
    }
    // 为了避免内存分配对齐的问题，应该将同一类型的基本数据类型调整在一起
    bool        isWheelSupported_;              // bool bSmartWW;
    bool        openWarnOnClose_;
    bool        openTabBlinking_;
    bool        replyENQ_;

    bool        openUrlCheck_;
    bool        openAntiAlias_;                  // bool bAutoCopy;
    bool        openMinimizeToTray_;
    bool        needClearZmodemPoolOnClose_;

    bool        useStyleSheet_;
    bool        isBossColor_;                   //global settings
    bool        isAnsciiEnhance_;
    bool        runServer_;

    int         displayOffset_;
    int         vsetting_;
    int         imeEncodingID_;                 //	0--GBK	1--BIG5
    int         widthToWrapWord_;
    int         openBeep_;
    int         beepMethodID_;
    int         termScrollBarPosition_;         // 0--hide 1--LEFT 2--RIGHT

    QString     httpBrowser_;                   // bool bLogMsg;

    QString     beepSoundFileName_;

    QString     beepPlayerName_;

    QString     styleSheetFile_;
    QString     zmodemDir_;
    QString     poolDir_;
    QString     imageViewerName_;
    QString     externalEditor_;
    QString     externalEditorArg_;
    QString     searchEngine_;
    QString     escapeString_;

};


class FQTermParam
{
public:
    FQTermParam();
    FQTermParam(const FQTermParam &);
    ~FQTermParam();

    FQTermParam &operator = (const FQTermParam &);

    bool operator==(const FQTermParam &);

    static const FQTermParam& getFQBBSParam();
    static QString getLanguageName(bool isEnglish, bool translate = true);
public:

    bool        isAutoLogin_;               // Auto Login
    bool        isAlwaysHighlight_;         // Always Highlight
    bool        isAnsiColor_;               // ANSI Color
    bool        isAutoReconnect_;           // Reconnect When Disconnected By Host

    bool        isAutoCloseWin_;            // Close Window When Disconnected By Host
    bool        isBeep_;
    bool        isBuzz_;
    bool        isAutoLoadScript_;          // Script

    bool        enableZmodem_;              // Zmodem
    bool        isColorCopy_;
    bool        isRectSelect_;
    bool        isAutoCopy_;

    bool        isAutoWrap_;
    bool        isAntiIdle_;
    bool        isAutoReply_;               // whether autoreply
    bool        isAuthentation_;            // Authentation

    bool        isSupportMouse_;            // Mouse

    quint16     port_;
    quint16     proxyPort_;                 // Port

    int         hostType_;                  // Host Type 0--BBS 1--*NIX
    int         serverEncodingID_;          //Display {FQTERM_ENCODING_GBK = 0, FQTERM_ENCODING_BIG5 = 1, FQTERM_ENCODING_UTF8 = 2, FQTERM_ENCODING_HKSCS = 3, FQTERM_ENCODING_UAO = 4};

    // 0 - keep column/row, adjust font
    // 1 - keep font, adjust column/row
    // 2 - keep column/row/font
    int         isFontAutoFit_;
    int         englishFontSize_;           // Font Size
    int         otherFontSize_;
    int         alignMode_;                 //how to align english char/chinese char in vertical direction 0 -- vcenter, 1 -- bottom 2 -- top
    int         charSpacing_;               //additional char spacing for English char.
    int         lineSpacing_;               //additional line spacing
                                            //int charRatio_; //height of english char / width of english char
    int         backspaceType_;             //0--^H 1--^?(127)
    int         keyboardType_;              // 0--BBS 1--XTERM 2--VT100
    int         numColumns_, numRows_;      // Columns & Rows
    int         numScrollLines_;            // Scroll Lines
    int         cursorType_;                //Curor Type 0--Block 1--Underline 2--I Type
    int         proxyType_;                 // Proxy Type0--None 1--Wingate 2--SOCKS4 3--SOCKS5 4--HTTP
    int         reconnectInterval_;         // Reconnect Interval (s)
    int         retryTimes_;                // Retry times -1 -- infinite
    int         menuType_;                  // 0--underline 1--reverse 2--color
    int         protocolType_;              // Protocol 0--Telnet 1--SSH1 2--SSH2 3--Local
    int         maxIdleSeconds_;            // Max Idle Time %s

    QString     name_;
    QString     hostAddress_;               // Address
    QString     preLoginCommand_;           // Pre Login
    QString     userName_;                  // User Name
    QString     password_;                  // Password
    QString     postLoginCommand_;          // Post Login
    QString     englishFontName_;           // Font Name
    QString     otherFontName_;
    QString     schemaFileName_;            // Schema File
    QString     virtualTermType_;           // Terminal Type
    QString     escapeString_;              // the esacpe string
    QString     proxyHostName_;             // Address
    QString     proxyUserName_;             // User Name
    QString     proxyPassword_;             // Password
    QString     sshUserName_;               // User Name
    QString     sshPassword_;               // Password
    QString     replyKeyCombination_;       // Misc
    QString     antiIdleMessage_;           // Send When Idle
    QString     autoReplyMessage_;          // Auto Reply Messages
    QColor      menuColor_;
    QString     autoLoadedScriptFileName_;

    QColor      backgroundColor_;           // Background Color
    QColor      foregroundColor_;           // Foreground Color

private:
    void copy(const FQTermParam& parm);
};

}  // namespace FQTerm

#endif  // FQTERM_PARAM_H
